//
//  MeetingView.m
//  Gxj
//
//  Created by 💋索少杰 on 2017/9/8.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "MeetingView.h"

@interface MeetingView ()<UIPickerViewDelegate,UIPickerViewDataSource>
{
    NSArray *_province;
    NSDictionary *_city;
}
@property(nonatomic, strong)UIPickerView *picker;



@end

@implementation MeetingView

- (instancetype) initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]) {
        
        //设置阴影
        _view1=[[UIView alloc] initWithFrame:CGRectMake(0, kWidthScale(30), UIScreenWidth, kHeightScale(120))];
        _view1.backgroundColor =[UIColor whiteColor];
        _view1.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
        [self addSubview:_view1];
        
        _iconImage=[[UIImageView alloc] init];
        _iconImage.image=[UIImage imageNamed:@"1111.jpg"];
        _iconImage.layer.masksToBounds=YES;
        _iconImage.layer.cornerRadius=10;
        [self addSubview:_iconImage];
        
        _iconImage.sd_layout
        .topSpaceToView(self, kHeightScale(40))
        .leftSpaceToView(self, kWidthScale(10))
        .widthIs(kWidthScale(100))
        .heightIs(kHeightScale(100));
        
        _textContent=[[UITextField alloc] init];
        _textContent.placeholder=@"请输入会议标题";
        _textContent.textColor=[UIColor whiteColor];
        //_textContent.backgroundColor=[UIColor orangeColor];
        _textContent.font=[UIFont systemFontOfSize:kWidthScale(20)];
        [self addSubview:_textContent];
        
        _textContent.sd_layout
        .topSpaceToView(self, kHeightScale(40))
        .leftSpaceToView(self.iconImage, kWidthScale(10))
        .rightSpaceToView(self, kWidthScale(10))
        .heightIs(kHeightScale(60));
        //虚线
        _link1= [[UIImageView alloc] init];
        _link1.image = [UIImage imageNamed:@"hui"];
        [self addSubview:_link1];
        
        _link1.sd_layout
        .topSpaceToView(self.textContent, kHeightScale(0))
        .leftSpaceToView(self.iconImage, kWidthScale(10))
        .rightSpaceToView(self, kWidthScale(10))
        .heightIs(kHeightScale(1));
        //会议标题
        _labelText=[[UILabel alloc] init];
        _labelText.text=@"请选择会议标题";
        _labelText.textColor=[UIColor whiteColor];
        _labelText.font=[UIFont systemFontOfSize:kWidthScale(14)];
        //_labelText.backgroundColor=[UIColor orangeColor];
        [self addSubview:_labelText];
        
        _labelText.sd_layout
        .topSpaceToView(self.link1, kHeightScale(12))
        .leftSpaceToView(self.iconImage, kWidthScale(10))
        .widthIs(kWidthScale(100))
        .autoHeightRatio(0);
        //商业标签
        NSArray*arr=@[@"shangye",@"fuzhuang",@"UI"];
        for (int i = 0; i < arr.count; i++) {
            _imageBiaoqian = [[UIImageView alloc] initWithFrame:CGRectMake(kWidthScale(225) * (i+1) - (190*i), kHeightScale(114), kWidthScale(35), kHeightScale(15))];
            _imageBiaoqian.image = [UIImage imageNamed:arr[i]];
            [self addSubview:_imageBiaoqian]; //  最佳评论用户头像
        }
        
        _timeText=[[UILabel alloc] init];
        _timeText.text=@"请选择会议发布时间";
        _timeText.textColor=[UIColor whiteColor];
        _timeText.font=[UIFont systemFontOfSize:kWidthScale(14)];
        //_timeText.backgroundColor=[UIColor orangeColor];
        [self addSubview:_timeText];
        
        _timeText.sd_layout
        .topSpaceToView(self.view1, kHeightScale(10))
        .leftSpaceToView(self, kWidthScale(10))
        .widthIs(kWidthScale(130))
        .autoHeightRatio(0);
        
        //编辑会议输入框 透明度
        _view4=[[UIView alloc] init];
        _view4.backgroundColor =[UIColor whiteColor];
        _view4.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
        _view4.layer.masksToBounds=YES;
        _view4.layer.cornerRadius=10;
        [self addSubview:_view4];
        
        _view4.sd_layout
        .topSpaceToView(self.view1, kHeightScale(200))
        .leftSpaceToView(self, kWidthScale(10))
        .rightSpaceToView(self, kWidthScale(10))
        .heightIs(kHeightScale(160));
        
        //发布会议按钮
        _fabuMeeting=[[UIButton alloc] init];
        [_fabuMeeting setBackgroundImage:[UIImage imageNamed:@"fabuhuiyibg123"] forState:UIControlStateNormal];
        [self addSubview:_fabuMeeting];
        
        _fabuMeeting.sd_layout
        .bottomSpaceToView(self, kHeightScale(60))
        .leftSpaceToView(self, kWidthScale(10))
        .rightSpaceToView(self, kWidthScale(10))
        .heightIs(kHeightScale(40));
        
        
        [self setPickerView];
    }
    
    return self;
}
- (void)setPickerView{
    
    //小时
    _province=@[@"1时",@"2时",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12"];
    
    //分钟
    _city = @{
              @"1时":@[@"01分", @"02", @"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",@"35",@"36",@"37",@"38",@"39",@"40",@"41",@"42",@"43",@"44",@"45",@"46",@"47",@"48",@"49",@"50",@"51",@"52",@"53",@"54",@"55",@"56",@"57",@"58",@"59",@"60"]
              };
    _picker=[[UIPickerView alloc] init];
    //_picker.backgroundColor=[UIColor orangeColor];
    _picker.delegate = self;
    _picker.dataSource = self;
    [self addSubview:_picker];
    
    _picker.sd_layout
    .topSpaceToView(self.timeText, kHeightScale(20))
    .leftSpaceToView(self, kWidthScale(40))
    .rightSpaceToView(self, kWidthScale(40))
    .heightIs(kHeightScale(55));
    
    _imageTime=[[UIImageView alloc] init];
    _imageTime.image=[UIImage imageNamed:@"shijian"];
    [self addSubview:_imageTime];
    
    _imageTime.sd_layout
    .topSpaceToView(self, kHeightScale(216))
    .leftSpaceToView(self, kWidthScale(170))
    .widthIs(kWidthScale(10))
    .heightIs(kHeightScale(14));
    
//    _view2=[[UIView alloc] init];
//    _view2.backgroundColor =[UIColor whiteColor];
//    _view2.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
//    [self addSubview:_view2];
//    _view2.sd_layout
//    .topSpaceToView(self, kHeightScale(210))
//    .leftSpaceToView(self, kWidthScale(100))
//    .widthIs(kWidthScale(124/2))
//    .heightIs(kHeightScale(72/2));
    
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 2;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
{
    if (component == 0)
    {
        return 80;
    }
    else
    {
        return 160;
    }
    
    return 0;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
    return 60;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    switch (component) {
        case 0:
        {
            return _province.count;
        }
            break;
        case 1:
        {
            NSInteger integer=[pickerView selectedRowInComponent:0];
            NSString *province =_province[integer];
            NSArray *citys = [_city objectForKey:province];
            
            return citys.count;
        }
            break;
            
            break;
        default:
            break;
    }
    
    return 0;
}
- (nullable NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    switch (component) {
        case 0:
        {
            return _province[row];
        }
            break;
        case 1:
        {
            NSInteger integer=[pickerView selectedRowInComponent:0];
            NSString *province = _province[integer];
            NSArray *citys = [_city objectForKey:province];
            
            return citys[row];
            
        }
            break;
            
        default:
            break;
    }
    
    return nil;
}

@end
